<?php

namespace App\Models;

use App\Helpers\Api\SearchTrait;
use Illuminate\Database\Eloquent\Model;

class Base extends Model
{
    use SearchTrait;
    protected $guarded = [];

    //$topics = Topic::limit(2)->withCertain('user', ['username'])->get();
    public function scopeWithCertain($query, $relation, Array $columns)
    {
        return $query->with([$relation => function ($query) use ($columns){
            $query->select(array_merge(['id'], $columns));
        }]);
    }

}